﻿<metro:MetroWindow x:Class="TV_Organizer.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:metro="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                   xmlns:tvo="clr-namespace:TV_Organizer"
                   xmlns:tvofs="clr-namespace:TV_Organizer.FileScanner"
                   xmlns:tvop="clr-namespace:TV_Organizer.Properties"
                   xmlns:tvos="clr-namespace:TV_Organizer.Subtitles"
                   xmlns:wpfExt="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"
                   Title="TV Organizer" Width="1024" Height="768"
                   MinWidth="500" MinHeight="300" ShowTitleBar="True" WindowStartupLocation="CenterOwner">
  <metro:MetroWindow.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Icons/MergedResources.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    
  </metro:MetroWindow.Resources>

  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="*" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <TabControl Grid.Row="1">
      <!--  File scanner  -->
      <TabItem Header="File scanner">
        <tvofs:FileScannerControl x:Name="FileScannerControl" />
      </TabItem>

      <!--  File scanner  -->
      <TabItem Header="Subtitles">
        <tvos:SubtitlesControl x:Name="SubtitlesControl" />
      </TabItem>

      <!--  Preferences  -->
      <TabItem Header="Preferences">
        <tvo:PreferencesControl />
      </TabItem>

      <!--  Logs  -->
      <TabItem Header="Logs">
        <ListView ItemsSource="{x:Static tvo:LogsManager.Logs}">
          <ListView.View>
            <GridView>
              <GridView.Columns>
                <GridViewColumn DisplayMemberBinding="{Binding Time}" Header="Time" />
                <GridViewColumn DisplayMemberBinding="{Binding Category}" Header="Category" />
                <GridViewColumn DisplayMemberBinding="{Binding Message}" Header="Message" />
              </GridView.Columns>
            </GridView>
          </ListView.View>
        </ListView>
      </TabItem>
    </TabControl>
    
    <!-- Busy indicator -->
    <wpfExt:BusyIndicator x:Name="BusyIndicator" Grid.ColumnSpan="10" Grid.RowSpan="10">
      <wpfExt:BusyIndicator.BusyContentTemplate>
        <DataTemplate>
          <StackPanel Margin="4" MinWidth="200">
            <TextBlock FontWeight="Bold" HorizontalAlignment="Center"
                       Text="{Binding BusyHeader, RelativeSource={RelativeSource AncestorType=tvo:MainWindow}}" />
            <StackPanel Margin="4">
              <TextBlock Text="{Binding BusyMessage, RelativeSource={RelativeSource AncestorType=tvo:MainWindow}}" />
              <TextBlock Margin="5,0,0,0"
                         Visibility="{Binding ProgressBarVisibility, RelativeSource={RelativeSource AncestorType=tvo:MainWindow}}">
                <TextBlock.Text>
                  <MultiBinding StringFormat="{}{0}/{1}">
                    <Binding Path="ProgressBarValue" RelativeSource="{RelativeSource AncestorType=tvo:MainWindow}" />
                    <Binding Path="ProgressBarMaximum" RelativeSource="{RelativeSource AncestorType=tvo:MainWindow}" />
                  </MultiBinding>
                </TextBlock.Text>
              </TextBlock>
              <ProgressBar Height="15"
                           Visibility="{Binding ProgressBarVisibility, RelativeSource={RelativeSource AncestorType=tvo:MainWindow}}"
                           Minimum="{Binding ProgressBarMinimum, RelativeSource={RelativeSource AncestorType=tvo:MainWindow}}"
                           Value="{Binding ProgressBarValue, RelativeSource={RelativeSource AncestorType=tvo:MainWindow}}"
                           Maximum="{Binding ProgressBarMaximum, RelativeSource={RelativeSource AncestorType=tvo:MainWindow}}" />
            </StackPanel>
          </StackPanel>
        </DataTemplate>
      </wpfExt:BusyIndicator.BusyContentTemplate>
      
      <!--<wpfExt:BusyIndicator.OverlayStyle>
        <Style TargetType="Rectangle">
          <Setter Property="Fill" Value="#ffffeeee"/>
        </Style>
      </wpfExt:BusyIndicator.OverlayStyle>-->
      
      <wpfExt:BusyIndicator.ProgressBarStyle>
        <Style TargetType="ProgressBar">
          <Setter Property="Visibility" Value="Collapsed"/>
        </Style>
      </wpfExt:BusyIndicator.ProgressBarStyle>
      
      <!--<ContentControl Style="{StaticResource SampleContent}"/>-->
    </wpfExt:BusyIndicator>
    
    <!-- Notifications -->
    <Grid x:Name="NotificationGrid" Grid.RowSpan="10" Grid.ColumnSpan="10" Width="0" Height="75" Margin="0,100,0,0"
          HorizontalAlignment="Right" VerticalAlignment="Top">
      <Grid.Resources>
        <Storyboard x:Key="OpenSB">
          <DoubleAnimation Storyboard.TargetName="NotificationGrid" Storyboard.TargetProperty="Width" From="0" To="300" Duration="00:00:00.5">
            <DoubleAnimation.EasingFunction>
              <SineEase />
            </DoubleAnimation.EasingFunction>
          </DoubleAnimation>
        </Storyboard>
        <Storyboard x:Key="CloseSB">
          <DoubleAnimation Storyboard.TargetName="NotificationGrid" Storyboard.TargetProperty="Width" From="300" To="0" Duration="00:00:00.5">
            <DoubleAnimation.EasingFunction>
              <SineEase />
            </DoubleAnimation.EasingFunction>
          </DoubleAnimation>
        </Storyboard>
      </Grid.Resources>

      <Grid.BitmapEffect>
        <DropShadowBitmapEffect ShadowDepth="5" Opacity="0.5" />
      </Grid.BitmapEffect>

      <Border Padding="10" Width="300" HorizontalAlignment="Left" VerticalAlignment="Stretch"
              Background="White" BorderThickness="1" BorderBrush="DarkBlue" >
        <TextBlock x:Name="NotificationTextBlock" VerticalAlignment="Center" HorizontalAlignment="Stretch" TextAlignment="Left"
                 TextWrapping="Wrap" TextTrimming="CharacterEllipsis" />
      </Border>
    </Grid>

  </Grid>
</metro:MetroWindow>
